/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package app;

import creature.AntCreature;
import creature.PredatorCreature;
import java.util.ArrayList;
import place.TargetPlace;
import processing.core.PApplet;
import processing.core.PVector;
import world.StateRepository;

/**
 *
 * @author user
 */
public class AntGameTest extends PApplet {
    public final static int ANT = 1;
    public final static int PREDATOR = 2;

    int addMode;
    private StateRepository state;

    @Override
    public void setup() {
        size(640, 480);
        smooth();
        ellipseMode(CENTER);
        rectMode(CENTER);

        addMode = 1;
        state = new StateRepository();
    }

    @Override
    public void draw() {
        background(255);

        for(TargetPlace t : state.getTargets()) {
            t.display();
        }

        strokeWeight(2);
        for(AntCreature a : state.getAnts()) {
            a.update();
            a.display();
        }

        for(PredatorCreature p : state.getPredators()) {
            p.update();
            p.display();
        }
    }

    @Override
    public void mousePressed() {
        if(mouseButton == LEFT) {
            if(addMode == ANT) {
                state.addAnt(new AntCreature(this, state, new PVector(mouseX, mouseY)));
            }
            else {
                state.addPredator(new PredatorCreature(this, state, new PVector(mouseX, mouseY)));
            }
        
        }
        else {
            state.addTarget(new TargetPlace(this, new PVector(mouseX, mouseY)));
        }
    }

    @Override
    public void keyPressed() {
        
            if(key == 'a' || key == 'A') {
                addMode = ANT;
            }
            else if(key == 'b' || key == 'B') {
                addMode = PREDATOR;
            }
            System.out.println("addMode" + addMode);
        
    }

}
